package c.j.a.d.a;

import android.text.TextUtils;
import c.b.a.a.a;
import org.json.JSONObject;

/* compiled from: AntiHijackAttempt */
public class d {
    public String a;
    public int b = -1;
    public String c;
    public String d;
    public String e;

    public static d a(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        d dVar = new d();
        try {
            JSONObject jSONObject = new JSONObject(str);
            dVar.e = jSONObject.optString("device_plans", null);
            dVar.d = jSONObject.optString("real_device_plan", null);
            dVar.c = jSONObject.optString("error_msg", null);
            dVar.a = jSONObject.optString("anti_plan_type", null);
            str = jSONObject.optString("error_code");
            if (TextUtils.isEmpty(str)) {
                dVar.b = -1;
            } else {
                dVar.b = Integer.parseInt(str);
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return dVar;
    }

    public void b(JSONObject jSONObject) {
        try {
            jSONObject.put("anti_plan_type", this.a);
            jSONObject.put("error_code", String.valueOf(this.b));
            jSONObject.put("error_msg", this.c);
            jSONObject.put("real_device_plan", this.d);
            jSONObject.put("device_plans", this.e);
        } catch (Throwable unused) {
        }
    }

    public String toString() {
        StringBuilder g = a.g("AntiHijackAttempt{anti_plan_type='");
        a.v(g, this.a, '\'', ", error_code=");
        g.append(this.b);
        g.append(", error_msg='");
        a.v(g, this.c, '\'', ", real_device_plan='");
        a.v(g, this.d, '\'', ", device_plans='");
        g.append(this.e);
        g.append('\'');
        g.append('}');
        return g.toString();
    }
}
